const fs = require("fs");
const { getDefaultSettings } = require("http2");
const path = require("path");

function delDir(filePath) {
    if(fs.existsSync(filePath)) {
        const files = fs.readdirSync(filePath);
        for(var i = 0; i < files.length; i++) {
            const childPath = path.join(filePath+"/"+files[i])
            const fileObj = fs.statSync(childPath);
            if(fileObj.isFile()){
                fs.unlinkSync(childPath);
            }
            else if(fileObj.isDirectory()){
                delDir(childPath)
            }
        }
        fs.rmdirSync(filePath);
    }
    else {
        console.log("文件路径不存在");
    }
}
const arg = process.argv[2];
const filePath = path.join(__dirname,"/"+arg);
delDir(filePath);